var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');

var options = {
    port: 465,
    host: 'smtp.163.com',
    secure: true,
    auth: {
        user: 'metrocloud@163.com',
        pass: 'getElementById()'
    }
};

// create reusable transporter object using SMTP transport
var transporter = nodemailer.createTransport(smtpTransport(options))

var dot = require('dot');
var path = require('path');
var fs = require('fs');
var origin = fs.readFileSync(path.join(__dirname, './file.dot'));

var render = dot.template(origin);
var htmlTxt = render({
    reviewer: '付和宽',
    realName: '李鸿章',
    phone: 110,
    mail: '110@163.com'
});

// setup e-mail data with unicode symbols
var mailOptions = {
    from: {
        name: '上勘院云监护平台',
        address: 'metrocloud@163.com'
    },
    // sender address
    to: '609602810@qq.com', // list of receivers
    subject: '有新用户需要审核', // Subject line
    html: htmlTxt // html body
};

// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info) {
    if (error) {
        console.log(error);
    } else {
        console.log('Message sent: ' + info.response);
    }
});
